package com.dawn.webmagic.file.core.example;

import com.dawn.webmagic.file.core.downloader.FileDownloader;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.model.OOSpider;
import us.codecraft.webmagic.model.annotation.ExtractBy;
import us.codecraft.webmagic.model.annotation.TargetUrl;
import us.codecraft.webmagic.pipeline.JsonFilePageModelPipeline;

import java.util.List;

/**
 * @author Ruffianjiang
 * @version V1.0
 * @Title: NotFount
 * @Package webmagic-demo
 * @date 2020/6/11 23:07
 */
@TargetUrl("c://temp//html//*.html")
@ExtractBy("div/text(1)//div[contains(text(),\"a\")]/following-sibling::node()[position() <= count( div/text(1)//div[contains(text(),\"e\")]/following-sibling::node()) + 1]")
public class FileAnnotationExample {

    @ExtractBy("//title/text()")
    private String title;

    @ExtractBy(value = "//span/text()")
    private List<String> tags;

    public String getTitle() {
        return title;
    }

    public List<String> getTags() {
        return tags;
    }


    public static void main(String[] args) {
        OOSpider.create(Site.me(), new JsonFilePageModelPipeline("c:/temp/webmagic/"), FileAnnotationExample.class)
                .setDownloader(new FileDownloader())
                .addUrl("c://temp//html//1234.html").run();
    }

}
